package com.yoke.controller.sysadmin;

import com.alibaba.fastjson.JSONArray;
import com.yoke.common.JsonMessage;
import com.yoke.common.base.NginxBaseControl;
import com.yoke.common.tools.AllUrl;
import com.yoke.system.log.LogType;
import com.yoke.system.log.SystemLog;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * Created by jiangzeyin on 2017/5/11.
 */
@Controller
@RequestMapping("sysadmin")
public class ListUrlAllControl extends NginxBaseControl {

    @RequestMapping(value = "listAll.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public String listAll() {
        JSONArray jsonArray;
        try {
            jsonArray = AllUrl.start(getConfPath());
        } catch (IOException e) {
            SystemLog.LOG(LogType.CONTROL_ERROR).error("获取失败", e);
            return JsonMessage.getString(100, "获取失败");
        }
        return JsonMessage.getString(200, "获取成功", jsonArray);
    }


}
